<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">



  
  
    
    
  <script src="/roee/lib/pace/pace.min.js?v=1.0.2"></script>
  <link href="/roee/lib/pace/pace-theme-flash.min.css?v=1.0.2" rel="stylesheet">







<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/roee/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/roee/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/roee/css/main.css?v=5.1.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="ReactNative,JavaScript," />








  <link rel="shortcut icon" type="image/x-icon" href="/roee/favicon.ico?v=5.1.2" />






<meta name="description" content="学习网址 基本概念一、容器属性ReactNative中flexDirection决定了主轴的方向column为垂直方向，row为水平方向123456flex-directionflex-wrap flex-flowjustify-contentalign-itemsalign-content 1.1 flex-direction属性flex-direction属性决定主轴的方向 123.box&amp;#">
<meta name="keywords" content="ReactNative,JavaScript">
<meta property="og:type" content="article">
<meta property="og:title" content="ReactNative布局学习--Flex Box">
<meta property="og:url" content="http://rjll.gitee.io/roee/2018/04/05/ReactNative布局学习-FlexBox/index.html">
<meta property="og:site_name" content="Roee&#39;s Blog">
<meta property="og:description" content="学习网址 基本概念一、容器属性ReactNative中flexDirection决定了主轴的方向column为垂直方向，row为水平方向123456flex-directionflex-wrap flex-flowjustify-contentalign-itemsalign-content 1.1 flex-direction属性flex-direction属性决定主轴的方向 123.box&amp;#">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://rjll.gitee.io/roee/2018/04/05/ReactNative布局学习-FlexBox/pic1.png">
<meta property="og:image" content="http://rjll.gitee.io/roee/2018/04/05/ReactNative布局学习-FlexBox/pic2.png">
<meta property="og:updated_time" content="2018-05-19T16:17:36.669Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="ReactNative布局学习--Flex Box">
<meta name="twitter:description" content="学习网址 基本概念一、容器属性ReactNative中flexDirection决定了主轴的方向column为垂直方向，row为水平方向123456flex-directionflex-wrap flex-flowjustify-contentalign-itemsalign-content 1.1 flex-direction属性flex-direction属性决定主轴的方向 123.box&amp;#">
<meta name="twitter:image" content="http://rjll.gitee.io/roee/2018/04/05/ReactNative布局学习-FlexBox/pic1.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/roee/',
    scheme: 'Gemini',
    sidebar: {"position":"left","display":"always","offset":12,"offset_float":12,"b2t":false,"scrollpercent":true,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://rjll.gitee.io/roee/2018/04/05/ReactNative布局学习-FlexBox/"/>





  <title>ReactNative布局学习--Flex Box | Roee's Blog</title>
  














</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/roee/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Roee's Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/roee/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/roee/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-romantic">
          <a href="/roee/520/romanticPage.html" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-heart"></i> <br />
            
            R❤️W
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/roee/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/roee/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://rjll.gitee.io/roee/roee/2018/04/05/ReactNative布局学习-FlexBox/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Roee">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/roee/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Roee's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">ReactNative布局学习--Flex Box</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-04-05T21:39:00+08:00">
                2018-04-05
              </time>
            

            

            
          </span>

          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/roee/2018/04/05/ReactNative布局学习-FlexBox/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count disqus-comment-count"
                        data-disqus-identifier="2018/04/05/ReactNative布局学习-FlexBox/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p><a href="http://www.ruanyifeng.com/blog/2015/07/flex-grammar.html?^%$" target="_blank" rel="noopener">学习网址</a></p>
<h1 id="基本概念"><a href="#基本概念" class="headerlink" title="基本概念"></a>基本概念</h1><h1 id="一、容器属性"><a href="#一、容器属性" class="headerlink" title="一、容器属性"></a>一、容器属性</h1><p>ReactNative中flexDirection决定了主轴的方向<br><b>column</b>为垂直方向，<b>row</b>为水平方向<br><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">flex-direction</span><br><span class="line">flex-wrap </span><br><span class="line">flex-flow</span><br><span class="line">justify-content</span><br><span class="line">align-items</span><br><span class="line">align-content</span><br></pre></td></tr></table></figure></p>
<h2 id="1-1-flex-direction属性"><a href="#1-1-flex-direction属性" class="headerlink" title="1.1 flex-direction属性"></a>1.1 flex-direction属性</h2><p>flex-direction属性决定主轴的方向</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">.box&#123;</span><br><span class="line">    flex-direction: row | row-reverse | column | column-reverse;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<ul>
<li>row 主轴为水平方向，容器中各组件从左到右排列</li>
<li>row-reverse 主轴为水平方向，容器中各组件从右到左排列</li>
<li>column 主轴为垂直方向，各组建从上到下排列</li>
<li>column-reverse 主轴为垂直方向，个组件从下到上排列</li>
</ul>
<p>flexDirection为row时，justifyContent指定容器内<b>水平方向</b>项目的对齐方式，alignItems指定容器内<b>垂直方向</b>上项目的对齐方式</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">View</span> <span class="attr">style</span>=<span class="string">&#123;&#123;height:</span> <span class="attr">400</span>, <span class="attr">flexDirection:</span> '<span class="attr">row</span>', <span class="attr">justifyContent:</span> '<span class="attr">center</span>', <span class="attr">alignItems:</span> '<span class="attr">center</span>'&#125;&#125;&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">View</span> <span class="attr">style</span>=<span class="string">&#123;&#123;backgroundColor:</span> '<span class="attr">green</span>', <span class="attr">margin:</span> <span class="attr">10</span>, <span class="attr">width:</span> <span class="attr">50</span>, <span class="attr">height:50</span>&#125;&#125;&gt;</span><span class="tag">&lt;<span class="name">Text</span>&gt;</span>1<span class="tag">&lt;/<span class="name">Text</span>&gt;</span><span class="tag">&lt;/<span class="name">View</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">View</span> <span class="attr">style</span>=<span class="string">&#123;&#123;backgroundColor:</span> '<span class="attr">green</span>', <span class="attr">margin:</span> <span class="attr">10</span>, <span class="attr">width:</span> <span class="attr">50</span>, <span class="attr">height:50</span>&#125;&#125;&gt;</span><span class="tag">&lt;<span class="name">Text</span>&gt;</span>2<span class="tag">&lt;/<span class="name">Text</span>&gt;</span><span class="tag">&lt;/<span class="name">View</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">View</span> <span class="attr">style</span>=<span class="string">&#123;&#123;backgroundColor:</span> '<span class="attr">green</span>', <span class="attr">margin:</span> <span class="attr">10</span>, <span class="attr">width:</span> <span class="attr">50</span>, <span class="attr">height:50</span>&#125;&#125;&gt;</span><span class="tag">&lt;<span class="name">Text</span>&gt;</span>3<span class="tag">&lt;/<span class="name">Text</span>&gt;</span><span class="tag">&lt;/<span class="name">View</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">View</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p><img src="/roee/2018/04/05/ReactNative布局学习-FlexBox/pic1.png" alt="图一"></p>
<p>flexDirection为时column时，justifyContent指定容器内<b>垂直方向</b>项目的对齐方式<br><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">View</span> <span class="attr">style</span>=<span class="string">&#123;&#123;height:</span> <span class="attr">400</span>, <span class="attr">flexDirection:</span> '<span class="attr">column</span>', <span class="attr">justifyContent:</span> '<span class="attr">center</span>', <span class="attr">alignItems:</span> '<span class="attr">flex-start</span>'&#125;&#125;&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">View</span> <span class="attr">style</span>=<span class="string">&#123;&#123;backgroundColor:</span> '<span class="attr">green</span>', <span class="attr">margin:</span> <span class="attr">10</span>, <span class="attr">width:</span> <span class="attr">50</span>, <span class="attr">height:50</span>&#125;&#125;&gt;</span></span><br><span class="line">    	<span class="tag">&lt;<span class="name">Text</span>&gt;</span>1<span class="tag">&lt;/<span class="name">Text</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">View</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">View</span> <span class="attr">style</span>=<span class="string">&#123;&#123;backgroundColor:</span> '<span class="attr">green</span>', <span class="attr">margin:</span> <span class="attr">10</span>, <span class="attr">width:</span> <span class="attr">50</span>, <span class="attr">height:50</span>&#125;&#125;&gt;</span></span><br><span class="line">    	<span class="tag">&lt;<span class="name">Text</span>&gt;</span>2<span class="tag">&lt;/<span class="name">Text</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">View</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">View</span> <span class="attr">style</span>=<span class="string">&#123;&#123;backgroundColor:</span> '<span class="attr">green</span>', <span class="attr">margin:</span> <span class="attr">10</span>, <span class="attr">width:</span> <span class="attr">50</span>, <span class="attr">height:50</span>&#125;&#125;&gt;</span><span class="tag">&lt;<span class="name">Text</span>&gt;</span>3<span class="tag">&lt;/<span class="name">Text</span>&gt;</span><span class="tag">&lt;/<span class="name">View</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">View</span>&gt;</span></span><br></pre></td></tr></table></figure></p>
<p><img src="/roee/2018/04/05/ReactNative布局学习-FlexBox/pic2.png" alt="图二"></p>
<h2 id="1-2-flex-wrap属性"><a href="#1-2-flex-wrap属性" class="headerlink" title="1.2 flex-wrap属性"></a>1.2 flex-wrap属性</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">.box&#123;flex-wrap: wrap | no-Wrap | wrap-reverse&#125;</span><br></pre></td></tr></table></figure>
<ul>
<li>wrap 换行，第一行在上方</li>
<li>no-wrap 不换行</li>
<li>wrap-reverse 换行，第一行在下方（ReactNative不支持该值）</li>
</ul>
<h2 id="1-3-flex-flow"><a href="#1-3-flex-flow" class="headerlink" title="1.3 flex-flow"></a>1.3 flex-flow</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">.box&#123;flex-flow: &lt;flex-direction&gt; || &lt;flex-wrap&gt;&#125;</span><br></pre></td></tr></table></figure>
<p>flex-flow是flex-direction和flex-wrap的简写形式</p>
<h2 id="1-4-justify-content"><a href="#1-4-justify-content" class="headerlink" title="1.4 justify-content"></a>1.4 justify-content</h2><p><em>justify-content</em> 定义了项目在<b>主轴</b>上的对齐方式<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">.box&#123;</span><br><span class="line">    justify-content: flex-start | flex-end | center | space-between | space-around</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">- flex-start  (默认值)左对齐</span><br><span class="line">- flex-end 右对齐</span><br><span class="line">- center 居中</span><br><span class="line">- space-between 两端对齐，项目之间间隔相等</span><br><span class="line">- space-around 每个项目两侧的间隔相等，项目之间的间隔比项目与边框的间隔大一倍</span><br></pre></td></tr></table></figure></p>
<h2 id="1-5-align-items"><a href="#1-5-align-items" class="headerlink" title="1.5 align-items"></a>1.5 align-items</h2><p><em>align-items</em>定义了项目在<b>交叉轴</b>上的对齐方式</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">.box&#123;</span><br><span class="line">    align-items: flex-start | flex-end | center | baseline | stretch</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">- flex-start 交叉轴起点对齐（顶部对齐）</span><br><span class="line">- flex-end 交叉轴终点对齐 （底部对齐）</span><br><span class="line">- center 交叉轴中点对齐</span><br><span class="line">- baseline 项目的第一行文字基线对齐</span><br><span class="line">- stretch （默认值）若项目未设置高度或者设为auto，将占满整个容器高度（见名知意，也就是拉伸的意思，撑满整个将项目撑满整个容器）</span><br></pre></td></tr></table></figure>
<h2 id="1-6-align-content"><a href="#1-6-align-content" class="headerlink" title="1.6 align-content"></a>1.6 align-content</h2><p>属性定义了<a href="https://www.cnblogs.com/strangerqt/p/5094968.html" target="_blank" rel="noopener">多根轴线</a>的对齐方式。如果项目只有一根轴线，该属性不起作用。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">.box&#123;</span><br><span class="line">    align-content: flex-start | flex-end | center | stretch | space-between | space-around</span><br><span class="line">&#125;</span><br><span class="line">- flex-start 与交叉轴的起点对齐</span><br><span class="line">- flex-end 与交叉轴终点对齐</span><br><span class="line">- center 与交叉轴的中点对齐</span><br><span class="line">- stretch 轴线占满整个容器（默认）</span><br><span class="line">- space-between 与交叉轴的两端对齐，轴线之间间隔平均分布</span><br><span class="line">- space-around 每两根轴线之间间隔相等，所以轴线之间间隔比轴线与边框之间间隔大一倍</span><br></pre></td></tr></table></figure>
<h1 id="二、项目的属性"><a href="#二、项目的属性" class="headerlink" title="二、项目的属性"></a>二、项目的属性</h1><p>项目的属性<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">- order ReactNative不支持</span><br><span class="line">- flex-grow 项目放大比例</span><br><span class="line">- flex-shrink 项目缩小比例</span><br><span class="line">- flex-basis</span><br><span class="line">- flex</span><br><span class="line">- align-self</span><br></pre></td></tr></table></figure></p>
<h2 id="2-1-order属性（ReactNative不支持）"><a href="#2-1-order属性（ReactNative不支持）" class="headerlink" title="2.1 order属性（ReactNative不支持）"></a>2.1 order属性（ReactNative不支持）</h2><p>order 定义项目的排列顺序，数值越小越排列靠前<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">.item&#123;</span><br><span class="line">    order: &lt;integer&gt;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<h2 id="2-2-flex-grow属性"><a href="#2-2-flex-grow属性" class="headerlink" title="2.2 flex-grow属性"></a>2.2 flex-grow属性</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">.item&#123;</span><br><span class="line">    flex-grow: &lt;number&gt;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>如果所有项目的flex-grow属性都为1，则它们将等分剩余空间（如果有的话）。如果一个项目的flex-grow属性为2，其他项目都为1，则前者占据的剩余空间将比其他项多一倍。</p>
<h2 id="2-3-flex-shrink属性"><a href="#2-3-flex-shrink属性" class="headerlink" title="2.3 flex-shrink属性"></a>2.3 flex-shrink属性</h2><p>flex-shrink属性定义了项目的缩小比例，默认为1，即如果空间不足，该项目将缩小。<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">.item &#123;</span><br><span class="line">    flex-shrink: &lt;number&gt;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>如果所有项目的flex-shrink属性都为1，当空间不足时，都将等比例缩小。如果一个项目的flex-shrink属性为0，其他项目都为1，则空间不足时，前者不缩小。<br>负值对该属性无效。</p>
<h2 id="2-4-align-self属性"><a href="#2-4-align-self属性" class="headerlink" title="2.4 align-self属性"></a>2.4 align-self属性</h2><p>对应ReactNative中alignSelf属性，align-self属性允许单个item使用与其他项目不一样的对齐方式，可以覆盖align-items，默认值为auto，表示继承父元素的align-items属性<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">.item&#123;</span><br><span class="line">    align-self: auto | flex-start | flex-end | center | stretch | baseline</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/roee/tags/ReactNative/" rel="tag"># ReactNative</a>
          
            <a href="/roee/tags/JavaScript/" rel="tag"># JavaScript</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/roee/2018/01/01/2018之开篇/" rel="next" title="2018之开篇">
                <i class="fa fa-chevron-left"></i> 2018之开篇
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/roee/2018/04/13/在hexo博客中插入本地图片的方法/" rel="prev" title="在hexo博客中插入本地图片的方法">
                在hexo博客中插入本地图片的方法 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
        
  <div class="bdsharebuttonbox">
    <a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
    <a href="#" class="bds_douban" data-cmd="douban" title="分享到豆瓣网"></a>
    <a href="#" class="bds_sqq" data-cmd="sqq" title="分享到QQ好友"></a>
    <a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a>
    <a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a>
    <a href="#" class="bds_tieba" data-cmd="tieba" title="分享到百度贴吧"></a>
    <a href="#" class="bds_twi" data-cmd="twi" title="分享到Twitter"></a>
    <a href="#" class="bds_fbook" data-cmd="fbook" title="分享到Facebook"></a>
    <a href="#" class="bds_more" data-cmd="more"></a>
    <a class="bds_count" data-cmd="count"></a>
  </div>
  <script>
    window._bd_share_config = {
      "common": {
        "bdText": "",
        "bdMini": "2",
        "bdMiniList": false,
        "bdPic": ""
      },
      "share": {
        "bdSize": "16",
        "bdStyle": "0"
      },
      "image": {
        "viewList": ["tsina", "douban", "sqq", "qzone", "weixin", "twi", "fbook"],
        "viewText": "分享到：",
        "viewSize": "16"
      }
    }
  </script>

<script>
  with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='//bdimg.share.baidu.com/static/api/js/share.js?cdnversion='+~(-new Date()/36e5)];
</script>

      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div id="disqus_thread">
        <noscript>
          Please enable JavaScript to view the
          <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a>
        </noscript>
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/roee/images/avatar.jpg"
               alt="Roee" />
          <p class="site-author-name" itemprop="name">Roee</p>
           
              <p class="site-description motion-element" itemprop="description"></p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/roee/archives/">
                <span class="site-state-item-count">12</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/roee/tags/index.html">
                <span class="site-state-item-count">8</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/llMrRongll" target="_blank" title="github">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                    
                      github
                    
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#基本概念"><span class="nav-number">1.</span> <span class="nav-text">基本概念</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#一、容器属性"><span class="nav-number">2.</span> <span class="nav-text">一、容器属性</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-1-flex-direction属性"><span class="nav-number">2.1.</span> <span class="nav-text">1.1 flex-direction属性</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#1-2-flex-wrap属性"><span class="nav-number">2.2.</span> <span class="nav-text">1.2 flex-wrap属性</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#1-3-flex-flow"><span class="nav-number">2.3.</span> <span class="nav-text">1.3 flex-flow</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#1-4-justify-content"><span class="nav-number">2.4.</span> <span class="nav-text">1.4 justify-content</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#1-5-align-items"><span class="nav-number">2.5.</span> <span class="nav-text">1.5 align-items</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#1-6-align-content"><span class="nav-number">2.6.</span> <span class="nav-text">1.6 align-content</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#二、项目的属性"><span class="nav-number">3.</span> <span class="nav-text">二、项目的属性</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#2-1-order属性（ReactNative不支持）"><span class="nav-number">3.1.</span> <span class="nav-text">2.1 order属性（ReactNative不支持）</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-2-flex-grow属性"><span class="nav-number">3.2.</span> <span class="nav-text">2.2 flex-grow属性</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-3-flex-shrink属性"><span class="nav-number">3.3.</span> <span class="nav-text">2.3 flex-shrink属性</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-4-align-self属性"><span class="nav-number">3.4.</span> <span class="nav-text">2.4 align-self属性</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Roee</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Gemini
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
          <span id="scrollpercent"><span>0</span>%</span>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/roee/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/roee/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/roee/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/roee/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/roee/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/roee/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/roee/js/src/utils.js?v=5.1.2"></script>

  <script type="text/javascript" src="/roee/js/src/motion.js?v=5.1.2"></script>



  
  


  <script type="text/javascript" src="/roee/js/src/affix.js?v=5.1.2"></script>

  <script type="text/javascript" src="/roee/js/src/schemes/pisces.js?v=5.1.2"></script>



  
  <script type="text/javascript" src="/roee/js/src/scrollspy.js?v=5.1.2"></script>
<script type="text/javascript" src="/roee/js/src/post-details.js?v=5.1.2"></script>



  


  <script type="text/javascript" src="/roee/js/src/bootstrap.js?v=5.1.2"></script>



  


  

    
      <script id="dsq-count-scr" src="https://roee-1.disqus.com/count.js" async></script>
    

    
      <script type="text/javascript">
        var disqus_config = function () {
          this.page.url = 'http://rjll.gitee.io/roee/2018/04/05/ReactNative布局学习-FlexBox/';
          this.page.identifier = '2018/04/05/ReactNative布局学习-FlexBox/';
          this.page.title = 'ReactNative布局学习--Flex Box';
        };
        var d = document, s = d.createElement('script');
        s.src = 'https://roee-1.disqus.com/embed.js';
        s.setAttribute('data-timestamp', '' + +new Date());
        (d.head || d.body).appendChild(s);
      </script>
    

  




	





  








  





  

  

  

  
  
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
        }
      });
    </script>

    <script type="text/x-mathjax-config">
      MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
      });
    </script>
    <script type="text/javascript" src="//cdn.bootcss.com/mathjax/2.7.1/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
  


  

  

</body>
</html>
